#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
void InsertSort(int* a, int size)
{
	int i = 0;
	for (i = 0;i < size - 1;i++)
	{
		int end = i;
		int tmp = a[end + 1];
		while (end >= 0)
		{
			if (tmp < a[end])
			{
				a[end + 1] = a[end];
				end--;
			}
			else
			{
				break;
			}
		}
		a[end+1] = tmp;
	}
}
void ShellSort(int* a, int size)
{
	int gap = size;
	while(gap>1)
	{
		gap = gap / 3 + 1;
		for (int i = 0;i < size - gap;i++)
		{
			int end = i;
			int tmp = a[end + gap];
			while (end >= 0)
			{
				if (tmp < a[end])
				{
					a[end + gap] = a[end];
					end-=gap;
				}
				else
				{
					break;
				}
			}
			a[end + gap] = tmp;
		}
	}
}
int main()
{
	int a[] = { 66,32,53,13,57,99,45,23,78,32,11,64 };
	int size = sizeof(a) / sizeof(a[0]);
	int i = 0;
	for (i = 0;i < size;i++)
	{
		printf("%d ", a[i]);
	}
	printf("\n");
	InsertSort(a, size);//
	for (i = 0;i < size;i++)
	{
		printf("%d ", a[i]);
	}
	ShellSort(a,size);
	printf("\n");
	for (i = 0;i < size;i++)
	{
		printf("%d ",a[i]);
	}
	return 0;
}